<template>
  <div class="screenshot-container">
    <div class="row">
      <div class="label">圆角大小</div>
      <el-slider
        v-model="appConfigCurrent.border_radius"
        :min="0"
        :max="50"
        :step="1"
      />
      <span>{{ appConfigCurrent.border_radius }}px</span>
    </div>
    <div class="actions">
      <el-button type="primary" @click="save">保存</el-button>
      <el-button @click="reset">重置</el-button>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ElMessage } from "element-plus";
import { useAppConfig } from "@/hooks/useAppConfig";

const { appConfigCurrent, updateConfig, setConfig } =
  useAppConfig("screenshot");

async function save() {
  try {
    await updateConfig();
    ElMessage.success("保存成功");
  } catch (error) {
    ElMessage.error("保存失败: " + error);
  }
}
async function reset() {
  try {
    await setConfig({
      border_radius: 0,
    });
    ElMessage.success("重置成功");
  } catch (error) {
    ElMessage.error("重置失败: " + error);
  }
}
</script>

<style scoped lang="scss">
.screenshot-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  .row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
  }
  .row .label {
    width: 120px;
  }
  .actions {
    margin-top: 20px;
  }
  .tips {
    font-size: 12px;
    color: #666;
  }
}
</style>
